<template>
	<div class="main_div">
		<h1>登录页面</h1>

		<div class="login_div">
			<div class="login_div_input">
				用户名：<el-input v-model="form.name" style="width: 200px;" placeholder="请输入账号" />
			</div>
			<div class="login_div_input">
				密&nbsp;&nbsp;&nbsp;码：<el-input v-model="form.password" type="password" style="width: 200px;"
					placeholder="请输入密码" />
			</div>

			<div>
				<el-button type="success" @click="login()">登录</el-button>
				<el-button @click="enroll()">注册</el-button>
			</div>
		</div>

	</div>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					name: null,
					password: null
				}
			}
		},
		methods: {
			//登录的方法
			login() {
				this.$.ajax({
					type: "POST",
					url: "/user/login",
					data: this.form,
					success: (result) => {
						console.log("登录请求....", result);
						localStorage.setItem("user", JSON.stringify(result));
						//跳转到首页
						this.$router.push("/ShowShop");
					}
				});
			},
			enroll() {
				this.$router.push("/enroll");
			}
		}
	}
</script>

<style>
	.main_div {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	.login_div {
		width: 600px;
		height: 300px;
		border-radius: 20px;
		box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
		display: flex;
		flex-direction: column;
		justify-content: space-evenly;
	}

	.login_div_input {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
	}
</style>